package Var1018;

import Chapter01.Visitor;

import java.util.Scanner;

public class Fifth {
    //7.游客那题：一个景区根据游人的年龄收取不同价格的门票。请编写游人类，根据年龄段决定能够购买的门票价格并输出
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String answer="";
        Visitor v = new Visitor();
        System.out.print("请输入姓名:");
        v.name = input.next();
        System.out.print("请输入年龄:");
        v.age = input.nextInt();
        v.show();

    }
    public static class Visitor {
    String name;
    int age;

    public void show(){
        Scanner input = new Scanner(System.in);
        while(!name.equals("n")){
            if(age>=18 && age<=60){
                System.out.println(name+"的年龄为: "+age+",门票价格为:20元!\n");
            }else{
                System.out.println(name + "的年龄为:" + age + ",门票免费\n");
            }
            System.out.print("请输入姓名:");
            name = input.next();
            if(!name.equals("n")){
                System.out.print("请输入年龄:");
                age = input.nextInt();
            }
        }
        System.out.print("退出程序!");
    }
    }
}
